// client.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#define FIFO_PATH "/tmp/myfifo"
int main() {
    // 打开命名管道用于写入
    int fifo_fd = open(FIFO_PATH, O_WRONLY);
    if (fifo_fd == -1) {
        perror("Failed to open named pipe for writing");
        exit(EXIT_FAILURE);
    }
    const char* message = "Hello from client!";
    if (write(fifo_fd, message, strlen(message)) == -1) {
        perror("Write to named pipe failed");
        exit(EXIT_FAILURE);
    }
    // 关闭管道文件描述符
    close(fifo_fd);
    return 0;
}